package com.hema.auction.adapter;

import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hema.auction.R;
import com.hema.auction.bean.GoodsInfo;
import com.hema.auction.utils.Utils;

import java.util.List;

/**
 * author by john
 */

public class DifferenceOrderAdapter extends BaseQuickAdapter<GoodsInfo, BaseViewHolder> {
    public DifferenceOrderAdapter(List<GoodsInfo> data) {
        super(R.layout.layout_difference_order_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsInfo item) {
        helper.setText(R.id.tv_date, Utils.timedate(item.getFinalTime()));
        helper.setText(R.id.tv_status, "待付款");
        helper.setText(R.id.tv_market_price, Utils.priceFormat(mContext, item.getPrice()));
        helper.setText(R.id.tv_use_shopping_coin, Utils.priceFormat(mContext, item.getGwPrice()));
        helper.setText(R.id.tv_real_time_price, Utils.priceFormat(mContext, item.getFinalPrice()));
        ImageView view = helper.getView(R.id.iv_img);
        Glide.with(mContext).load(item.getImg()).into(view);
        helper.addOnClickListener(R.id.tv_action1).addOnClickListener(R.id.tv_action2);
        switch (item.getStatus()) {
            //订单状态  订单状态  0->未付款，1->已付款(待发货)，2->已发货(待签收)，3->已收货(待晒单)，4->已过期，5->已取消,6未竞拍结束
            case 0:
                helper.setText(R.id.tv_status, "待付款");

                helper.setText(R.id.tv_action1, "立即付款");
                helper.setVisible(R.id.tv_action1, true);
                helper.setVisible(R.id.tv_action2, false);

                break;
            case 1:
                helper.setText(R.id.tv_status, "已付款");

                helper.setVisible(R.id.tv_action1, false);
                helper.setText(R.id.tv_action2, "查看详情");
                helper.setVisible(R.id.tv_action2, true);
                break;
            case 2:
                helper.setText(R.id.tv_status, "已发货");

                helper.setVisible(R.id.tv_action1, false);
                helper.setText(R.id.tv_action2, "查看详情");
                helper.setVisible(R.id.tv_action2, true);
                break;
            case 3:
                helper.setText(R.id.tv_status, "已签收");

                helper.setText(R.id.tv_action1, "我要晒单");
                helper.setVisible(R.id.tv_action1, true);
                helper.setText(R.id.tv_action2, "查看详情");
                helper.setVisible(R.id.tv_action2, true);

                break;
            case 4:
                helper.setText(R.id.tv_status, "已过期");
                helper.setVisible(R.id.tv_action1, false);
                helper.setText(R.id.tv_action2, "查看详情");
                helper.setVisible(R.id.tv_action2, true);

                break;
            case 5:
                helper.setText(R.id.tv_status, "已完成");
                helper.setVisible(R.id.tv_action1, false);
                helper.setText(R.id.tv_action2, "查看详情");
                helper.setVisible(R.id.tv_action2, true);
                break;

        }
    }

}
